On Extending Java

ثبت نشده
چکیده

closely related to closures since they too can be nested in methods and classes. Their translation scheme follows the scheme described for closures. They are crucial for implementing iterators efficiently. Iterators are quite valuable as they permit encapsu-lation of iteration strategies within containers. In other words, the iteration algorithm, complete with its initialization code and termination condition, is hidden within the container data structure. This makes client code simpler and more robust. A translator implementing our extensions is available atTranslation Iterators are implemented using the exception mechanism of Java. Two new exceptions are defined, Break and Continue /*1*/. Inside an iterator method, a break at method level or labelled with the method name is translated to a throw of the exception Break /*2*/. Similar a continue is translated to a throw of the exception Continue. Each use of an iterator method is protected by a try which catches Break and Continue exceptions /*3*/. Only one try block for each loop nesting containing iterators is generated. The exception handler contains the break or continue statement optional extended by a label /*4*/. The loop keyword is just transformed into a while (true) /*5*/. Discussion The iterator concept presented here is more expressive than Sather's iters and allows an elegant encapsulation of iteration protocols. The translation scheme relies on closures and anonymous objects presented earlier. Exceptions are an efficient implementation technique. In Java they are very frequent and are often implemented as functions with two return values: the exception and the function return value. Our iterators are just that: methods with two return values. The exception setup and the iterator call overhead can be eliminated if the iterator is inlined. 7 Conclusions This paper proposes four non-intrusive language extensions, tuples, closures, anonymous objects and iterators, designed to improve the expressive power of Java without modifying the semantics of existing programs or complicating the language unduly. Tuples are useful on their own as typed heterogeneous containers of fixed size. Their real value is for efficiently implementing functions with multiple return values. In this respect they fit well with closures. Closures are first class functions. Their presence in the language makes it easy to express functions that manipulate other functions as is commonly done in functional programming. Anonymous objects are literal objects final class Break extends Exception {} /*1*/ final class Continue extends Exception {} /*1*/

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Supporting multidimensional arrays in Java

The lack of direct support for multidimensional arrays in JavaTM has been recognized as a major deficiency in the language’s applicability to numerical computing. It has been shown that, when augmented with multidimensional arrays, Java can achieve very high-performance for numerical computing through the use of compiler techniques and efficient implementations of aggregate array operations. Th...

متن کامل

Extending the Java Language with Dynamic Classification

The dynamic classification feature of an object-oriented programming language allows an object to change its class membership without changing its identity at runtime. The new membership of the object can be signified with a role, which is taken on by the object and which can be implemented as an object of the target class. Here, we propose an approach to extend the Java language with a dynamic...

متن کامل

Extending Camelot with Mutable State and Concurrency

Camelot is a resource-bounded functional programming language which compiles to Java byte code to run on the Java Virtual Machine. We extend Camelot to include language support for Camelot-level threads which are compiled to native Java threads. We extend the existing Camelot resource-bounded type system to provide safety guarantees about the heap usage of Camelot threads.

متن کامل

Extending Java to Support Component-Based Programming

Java Layers extends the Java programming language by implementing a software component model based on layer composition. Each layer implements a single design feature and may contain code that crosscuts multiple classes. Layer composition enables large software applications to be constructed in a more modular way, and with a higher level of semantic checking, than is typically achieved using cu...

متن کامل

Java Virtual Machine Interpreter : Porting and Extending . Final Report CSC 2227

This document describes the progress of the project on porting existing YETI [7] for x86 architecture. It shows what changes were made in the existing YETI project, gives short literature survey with some details in YETI design and describes what results were obtained on the SPECjvm98 benchmark.

متن کامل

Extending WordNet using Generalized Automated Relationship Induction

This paper describes a Java package for automatically extending WordNet and other semantic lexicons. Extending these semantic lexicons by traditional means of hand labeling word relationships is a very expensive and laborious process. We used machine learning techniques to automatically extract relationships between words from a given text corpus. The package is made to be very flexible, allowi...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1997